import { Body, Controller, Post, UseGuards } from '@nestjs/common';
import { LoginDto } from './dto/auth.dto';
import { AuthService } from './auth.service';
import { Public } from './decorators/public.decorator';
import { LocalGuard } from './guards/local.guard';
import { CaptchaService } from './services/captcha.service';
@UseGuards(LocalGuard)
@Public()
@Controller('auth')
export class AuthController {
  constructor(
    private readonly authService: AuthService,
    private captchaService: CaptchaService
  ) {}
  @Post('login')
  async login(@Body() dto: LoginDto) {
    await this.captchaService.checkImgCaptcha(dto.captchaId, dto.verifyCode);
    const userData = await this.authService.login(dto);
    return {
      accessToken: userData.accessToken,
      ...userData
    };
  }
  @Post('register')
  register(@Body() dto: any) {
    console.log(dto, 'dto');
    return '123';
  }
}
